﻿package cz.dadul.adventure.model
{
	/**
	 * ...
	 * @author Dadul
	 */
	import adobe.utils.CustomActions;
	import adobe.utils.ProductManager;
	import flash.display.*;
	import flash.events.*;
	import flash.geom.Point;
	
	public class Player extends Element implements IMovable 
	{
		public static const NAME:String = "player";
		
		private var _speed:int;
		
		[Embed(source='../../../../../lib/greenShape.swf', symbol='BigHit')]
		private var Hita:Class;
		
		public function Player(mc:MovieClip) 
		{
			mc.stop();
			super(Player.NAME, mc);
			/*	this._graphics = graphics;
			// Display objects
			addChild(graphics);			
			
			trace(this._graphics);
			
			
			
			var h:Sprite = new Hita();			
			h.mouseEnabled = false;
			this._graphics.hitArea = h;			
			
			*/

		}
		
		public function moveByKey(e:KeyboardEvent):void {
			//keycodes
			var left:uint = 37;
			var up:uint = 38;
			var right:uint = 39;
			var down:uint = 40;
			var speed:int = 5;
			
			switch(e.keyCode) {
				case left: x -= speed; break;
				case right: x += speed; break;
				case up: y -= speed; break;
				case down: y += speed; break;				
			}
			
			dispatchEvent(new Event("playerMoved"));
		}
		
		
		public function animate() : void{
			this._content.play();
		}
		
		public function moveToPoint(p:Point):void {
				
		}				
		
		public function moveTo(x:int, y:int):void {
			var bx:int = this.x;
			var by:int = this.y;
			// Test a boundary
			this.x = x;
			this.y = y;			
			
		}
		public function getHitZone():DisplayObject {
			return _content.getChildByName("hitZone");
		}
		
		
	}

}